﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DBLibrary;

public class UserConnectionConfig :IConnectionConfiguration
{
    private string mDBPre;
    public UserConnectionConfig(string dbPre = "")
    {
        mDBPre = dbPre;
    }
    public string ConnectionString
    {
        get
        {
            if (HttpContext.Current == null || HttpContext.Current.Session == null
                || HttpContext.Current.Session[HttpContext.Current.User.Identity.Name] == null)
            {
                if (string.IsNullOrEmpty(mDBPre))
                {
                    return string.Empty;
                }
                else
                {
                    return string.Format(@"Data Source=.\SQLEXPRESS;Initial Catalog=PoseidonDB_{0};Integrated Security=SSPI", mDBPre);
                }
            }
            else
            {
                return string.Format(@"Data Source=.\SQLEXPRESS;Initial Catalog=PoseidonDB_{0};Integrated Security=SSPI", HttpContext.Current.Session[HttpContext.Current.User.Identity.Name].ToString());
            }
        }
    }

    public string DbType
    {
        get { return "System.Data.SqlClient"; }
    }
}

public class AdminConnectionConfig : IConnectionConfiguration
{
    public string ConnectionString
    {
        get { return @"Data Source=.\SQLEXPRESS;Initial Catalog=PoseidonAdminDB;Integrated Security=SSPI"; }
    }

    public string DbType
    {
        get { return "System.Data.SqlClient"; }
    }
}